<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <title>日常管理--货位整理</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->


        <div class="comm_crub">
            <span class="now_crub">日常管理--货位整理</span>
        </div>

        <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" onsubmit="return false;" class="form-inline">
                        <table style="width:100%;">
                            <tbody>
                            <tr>
                                <td height="27px" style="text-align: left;padding-right: 20px;">
                                    <span>
                                        选择仓库：
                                        <select class="form-control input-sm" id='storeID' name='storeID'>
                                            <option value='-1'>请选择</option>
                                            <!--{foreach from=$store_array item=value}-->
                                            <option value='<!--{$value->storeID}-->'><!--{$value->storeName}--></option>
                                            <!--{/foreach}-->
                                        </select>
                                    </span>

                                     <span>
                                        筛选条件：
                                        <select class="form-control input-sm" id='select_condition' name='select_condition'>
                                            <option value="-1">请选择</option>
                                            <option value="1">货位号</option>
                                            <option value="2">商品编号</option>
                                            <option value="3">商品名称</option>
                                        </select>
                                         <input type="text" class="form-control input-sm" name="condition" id="condition" style="width: 130px;">
                                    </span>

                                    <span>
                                        <button type="button" class="btn btn-primary btn-sm" onclick="shelfManage.search();">查询</button>&nbsp;&nbsp;
                                        <button type="button" class="btn btn-primary btn-sm" onclick="shelfManage.clear();">重置</button>
                                        <!--{if $EDIT_STORESHELFMANAGE}-->
                                    &nbsp;&nbsp;
                                        <button type="button" class="btn btn-primary btn-sm" onclick="shelfManage.exportShelf();">导出</button>
                                        <!--{/if}-->
                                    </span>

                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

            <form name="export_form" id="export_form" method="post" action="/quanliadmin/app/wms/store.pscript?operFlg=14">
                <input type="hidden" name="v1" id="v1" value="">
                <input type="hidden" name="v2" id="v2" value="">
                <input type="hidden" name="v3" id="v3" value="">
            </form>

        </div>


</div>

<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/wms/storeShelfManage.ajax?operFlg=13&xjx=none",
        dataType: "json",
        colModel : [
        {display: "所在仓库", width : 100,align:"left"},
        {display: "货位号", width : 100,align:"left"},
        {display: "商品SKU", width : 200 , align:"left"},
        {display: "商品名称", width : 400,align:"left"}
        ],
        <!--{if $EDIT_STORESHELFMANAGE}-->
            buttons : [
                {name: "货品上架", bclass: "add", onpress : "shelfManage.add"},
                {separator: true},
                {name: "解绑", bclass: "delete", onpress : "shelfManage.delcheck"}
            ],
        <!--{/if}-->
        usepager: true,
        rp: 20,
        useRp: true,
        showTableToggleBtn: true,
        onSubmit: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    //条件选择事件
    $("#select_condition").change(function (){
        if($(this).val() == "1"){
            $("#condition").attr('name','shelf_name');
            $("#condition").focus();
        }else if($(this).val() == "2"){
            $("#condition").attr('name','product_code');
            $("#condition").focus();
        }else if($(this).val() == "3"){
            $("#condition").attr('name','goods_name');
            $("#condition").focus();
        }
    });

    var shelfManage = {

        delArr: new Array(),

        storeID:'',

        search : function (){
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //删除确认
        delcheck: function(){
            //获取选中的行的行数
            var selected_count = $('.trSelected',flex).length;
            if (selected_count==0) {
                E.alert('请选择要解绑的货位');
                return;
            }else{
                var tempArr = new Array();
                for(var i=0; i<selected_count; i++){
                    var storeShelf = $('.trSelected',flex).eq(i).attr('id');
                    var deleteStr = storeShelf.substr(3);
                    tempArr.push(deleteStr);
                }
                this.delArr = tempArr;

                //弹出确认层
                E.confirm('是否解绑这 ' + $('.trSelected',flex).length + ' 个库位吗?', "shelfManage.del");
            }

        },

        del:function(){
            $.ajax({
                type: "POST",
                url: "/invokingAjax-backend/wms/store.ajax?operFlg=14",
                dataType: "JSON",
                data:{'delArr': shelfManage.delArr},
                success: function(result_obj){
                    if (result_obj.code == 200) {
                        E.alert(result_obj.message, 2, "shelfManage.load");
                    }
                    else {
                        E.alert(result_obj.message);
                    }
                }
            });
        },

        exportShelf:function(){

            var storeID = $.trim($("#storeID").val());
            var field = $.trim($("#select_condition").val());
            var value = $.trim($("#condition").val());

            $("#v1").val( storeID );
            $("#v2").val( field );
            $("#v3").val( value );
            document.getElementById('export_form').submit();

        },

        //入库添加
        add:function(){

            self.location = '/quanliadmin/app/wms/store.pscript?operFlg=15&type=2';
        },

        //回调函数
        callback: function( obj ) {

            if( obj.code == 200 ){
                E.alert( obj.message , 2 , 'store.load');
            }else{
                E.alert(obj.message);
            }

        },

        load: function() {
            $("#flex").flexReload();
        },

        //重置
        clear : function (){
            $("#storeID").val("-1");
            $("#select_condition").val("-1");
            $("#condition").val("");
            $("#condition").attr("name" , "condition");
        }

    };


    function jquery_ajax(flg,data,func){
        $.ajax({
            type: "post",
            url: "/invokingAjax-backend/wms/storeShelfManage.ajax?operFlg="+flg,
            dataType: "json",
            data: data,
            success: function( result_obj ) {
                func(result_obj);
            },
            error : function(msg){
                alert('网络不给力，请重新尝试...');
            }
        });
    }

</script>

</body>

</html>
